#!/bin/bash

#filename FileTypePlugin_Install.sh

#usage: install user-defined ftplugin files

# 1. create ftplugin in system

if [ ! -d ~/.vim/after/ftplugin ]; then
	echo "creating after/ftplugin dir for vim"
	mkdir -p ~/.vim/after/ftplugin
fi



#function to config filetype plugins for vim in system
function install_after_plugin {
	
	#filetype name
	filetype=$1

	#already configured file in current _vim folder
    after_specific_file=./_vim/after/ftplugin/${filetype}/specific.vim
	
	
    target_specific_file=~/.vim/after/ftplugin/${filetype}/specific.vim
	
	
	source_filetype_dir=./_vim/after/ftplugin/${filetype}
	target_filetype_dir=~/.vim/after/ftplugin/${filetype}
	
	if [[ -d $source_filetype_dir ]]; then
		echo "create filetype folder $target_filetype_dir"
		mkdir -p $target_filetype_dir
	fi
	
	#copy the already configured files into system vim .vim folder
	
	if [[ -f $after_specific_file ]]; then
		echo "copying $after_specific_file into $target_specific_file";
		cp $after_specific_file $target_specific_file
	fi
	
}

#you can using comment or delete comment to decided use which filetype you want
#plugin for java filetype
install_after_plugin java
#plugin for xhtml filetype
install_after_plugin xhtml
#plugin for html filetype
install_after_plugin html
#plugin for xml filetype
install_after_plugin xml
#plugin for markdown filetype
install_after_plugin markdown
#plugin for python filetype
install_after_plugin python
#plugin for sh filetype
install_after_plugin sh
#plugin for vim filetype
install_after_plugin vim
#plugin for zsh filetype
install_after_plugin zsh



